﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Palindrom_LongString_LiterMatches
{
    class FirstOrLastLiter
    {
        public static void PrintWordsWithFirstOrLastMatchLiter()
        {
            Console.WriteLine("Введите букву: ");
            string liter = Console.ReadLine();
            string textFile = @"C:\My files\HT.txt";
            string textFromFile = File.ReadAllText(textFile);
            string textFromFileFinal = textFromFile.Replace("\r\n\r\n", " ").Replace(",", "").Replace(".", "").Replace("(", "").Replace(")", "");
            string[] wordsFromTextOfFile = textFromFileFinal.Split(' ');
            for (int i = 0; i < wordsFromTextOfFile.Length; i++)
            {
                if ((wordsFromTextOfFile[i].StartsWith(liter) == true) || (wordsFromTextOfFile[i].EndsWith(liter) == true))
                        Console.WriteLine(wordsFromTextOfFile[i]);
            }
        }
    }
}
